<template>
	<view class="nameTable">
		<view  v-if="!auditShow">
			<other></other>
		</view>
		<view class="card">
			<view class="text">
				姓名打分
			</view>
			<view class="card_box">
		<view v-if="auditShow">
			<view class="nameTable_box">
				<view class="flex_row_start_center nameTable_item">
					<view class="nameTable_item_left">您的姓氏</view>
					<input v-model="form.firstname" placeholder-class="placeholder-class" placeholder="请输入您的姓氏" />
				</view>
			</view>
			<view class="nameTable_box">
				<view class="flex_row_start_center nameTable_item">
					<view class="nameTable_item_left">您的名字</view>
					<input v-model="form.lastname" placeholder-class="placeholder-class" placeholder="请输入您的名字" />
				</view>
			</view>
			<view class="nameTable_box">
				<view class="flex_row_start_center nameTable_item">
					<view class="nameTable_item_left">您的性别</view>
					<view class="flex_row_start_center">
						<view class="addArchives_sex" @click="changeSex(0)">
							<text  :class="form.gender == '男' ? 'cuIcon-roundcheckfill':'cuIcon-round'" class=" lg"></text>
							<text style="margin-left: 10rpx;">男</text>
						</view>
						<view class="addArchives_sex"  @click="changeSex(1)">
							<text :class="form.gender=='女' ? 'cuIcon-roundcheckfill':'cuIcon-round'" class=" lg"></text>
							<text style="margin-left: 10rpx;">女</text>
						</view>
					</view>
				</view>
			</view>
			<view class="nameTable_box" @click="showCalendar=true">
				<view class="flex_row_start_center nameTable_item">
					<view class="nameTable_item_left">出生日期</view>
					<view class="input">
						{{celenderValue}}
					</view>
					 <!-- <input v-model="celenderValue" @click="showCalendar=true"  placeholder-class="placeholder-class" placeholder="请选择日期" /> -->
					<e-run-calendar ref="betterCalendarRef" :showCalendar="showCalendar" @confirm="selectDate" :isHourShow="true"
					        @cancel="showCalendar = false" :selectOptions="selectOptionsArr"></e-run-calendar>
				</view>
			</view>
			<view class="nameTable_button"@click="natTo('/pages/moreModule/nameevaluation/namevalinfo')">确认</view>
			
		</view>
		</view>
		</view>
	</view>
</template>

<script>
	import eRunCalendar from "@/uni_modules/e-run-calendar/components/e-run-calendar/e-run-calendar.vue"
	import other from '@/components/other/index.vue'
	export default{
		components:{other,eRunCalendar},
		data(){
			return{
				auditShow:false,
				
				showCalendar: false,//是否显示组件
				// celenderValue: '请选择日期',//选择值
				selectOptionsArr: [80, 0, 0, 0],///起始年份
				form:{
					firstname:'',//姓氏
					lastname:'',//名
					gender:'男',
					year: null, 
					month:null, 
					day: null, 
					hour: null, 
					minute: null, 
					isLeap: null, 
				},
				celenderValue:'请选择日期',
			}
		},
		onLoad(){},
		onShow(){
			this.getAudit()
		},
		methods:{
			//获取微信审核开关
			getAudit(){
			    let param = {};
				param.url='v3/system/front/configuration/1'
				this.$request(param).then(res=>{
					console.log(res);
					this.auditShow=res.data.auditSwitch
					if(this.auditShow){
						uni.setNavigationBarTitle({
							title:'名字打分'
						})
					}
				})
			},
			changeSex(sex){
				this.form.gender=sex==0 ? '男':'女';
			},
			selectDate(e){
				console.log('e',e);
				if(e.type == 'solar'){
					//公历
					this.currentIndex=0
					this.form.isLeap=null
					this.form.year=e.year
					this.form.month=e.month
					this.form.day=e.day
					this.form.hour=(e.hour+1).toString().padStart(2, '0')
					this.form.minute="00"
					this.celenderValue=e.year+'/'+e.month+'/'+e.day+'/'+' '+(e.hour+1).toString().padStart(2, '0')+":"+'00'
				}else if(e.type == 'lunar'){
					//农历
					this.currentIndex=1
					this.celenderValue=e.year+'/'+e.month+'/'+e.day+'/'+' '+(e.hour+1).toString().padStart(2, '0')+":"+'00'
					//判断是否闰月
					this.form.year=e.year
					this.form.month=e.month
					this.form.day=e.day
					this.form.hour=(e.hour+1).toString().padStart(2, '0')
					this.form.minute="00"
					this.form.isLeap= e.leap_month == 1 ? 'true':'false'
				
				}
				console.log('this.form.masterBirthday',this.form.masterBirthday);
				this.showCalendar=false
			},
			natTo(url,item){
				// 要传递的对象参数
				if(!this.form.firstname){
					this.$modal.msg('请输入姓氏！')
					return false 
				}else if(!this.form.year){
					this.$modal.msg('请选择时间！')
					return false 
				}else if(!this.form.lastname){
					this.$modal.msg('请输入名字！')
					return false 
				}
				
				const obj = this.form
				console.log('obj',obj);
				
				// 将对象参数转为JSON字符串，并使用encodeURIComponent编码
				const params = encodeURIComponent(JSON.stringify(obj));
				
				// 跳转页面并传递对象参数
				uni.navigateTo({
				   url: `${url}?params=${params}`
				});
			},
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f4f4f4;
	}
	.card{
		background-color: #88b7ff;
		height: 500rpx;
		padding: 40rpx 30rpx;
		position: relative;
		.text{
					  padding-top: 50rpx;
					  font-size: 80rpx;
					  font-weight: 550;
					  width: 100%;
					  text-align: center;
					  color: #f9fefc;
		}
		.card_box{
			 position: absolute;
			 top: 230rpx;
			 left: 40rpx;
			 right: 40rpx;
		}
	}
	.nameTable{
		padding: 0rpx 0rpx 50rpx;
	}
	.nameTable_box{
		background-color: #fff;
		padding: 30rpx 40rpx;
	}
	.nameTable_item{
		padding: 10rpx 15rpx;
		font-size: 28rpx;
	    border-bottom: 2rpx solid #eeeeee;	
	}
	.nameTable_item_left{
		margin-right: 44rpx;
	}
	.nameTable_button{
		color: #fff;
		margin-top: 48rpx;
		border-radius: 15rpx;
		font-size: 36rpx;
		padding: 24rpx 0;
		text-align: center;
		background-color: #88b7ff;
		letter-spacing: 6rpx;
	}
	.addArchives_sex{
		width: 100rpx;
	}
</style>